#pragma once
#include <limits.h>
#include <stdlib.h>
#include <fstream>
#include <libxml/parser.h>
#include <string.h>
#include <inttypes.h>
#include <exception>
#include <vector>
#include <Peak.h>
#include <memory>
#include "../kernels/types.cl"

#define kMaxPartialScans 256


class ScanException : public std::exception
{
  protected:
    char* errString;
  public:
    ScanException(const char* errString)
    {   
      this->errString = (char*)errString;
    }   
    virtual const char* what()
    {   
      return this->errString;
    }   
};

typedef enum _Scan_DataPrecision
{
  kDataPrecisionSingle,
  kDataPrecisionDouble
}Scan_DataPrecision;

class Scan {
  public:
    std::unique_ptr<unsigned int[]> mMZ; //Mass to charge ratio in millidaltons
    std::unique_ptr<unsigned int[]> mIntensity; //Magnitude
    MSScanInfo mScanInfo;
    std::vector<std::shared_ptr<Scan>> mPartialScans; //MS^(n+1) scans
    Scan_DataPrecision mDataPrecision;
    
  public:
    Scan(xmlNode* scanNode, size_t& maxScanSize, Scan* parent = NULL);
    void fillFlatArrays(unsigned int*& peaksPtr, 
                        unsigned int*& mzPtr,
                        MSScanInfo*& scanInfoPtr,
                        unsigned int maxScanSize);
};
